package com.ddtech.business.practice.dto;


import com.ddtech.business.practice.entity.PracticeUserQuestion;
import com.ddtech.business.practice.entity.PracticeUserQuestionOption;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description 试题和选项
 * @Author luanh
 * @Date 2020-11-27
 */
@Data
@ApiModel
public class QueAndOptDto {

    @ApiModelProperty("主键id")
    private String id;
    /**
     * 用户id
     */
    @ApiModelProperty("添加用户id")
    private String userId;

    /**
     * 练习id
     */
    @ApiModelProperty("练习id")
    private String practiceId;

    @ApiModelProperty(value = "题库问题id")
    private String bankQuestionId;
    /**
     * 问题序号
     */
    @ApiModelProperty("问题序号")
    private Integer questionNum;

    /**
     * 试题描述
     */
    @ApiModelProperty("试题描述")
    private String questionDesc;

    /**
     * 试题图片
     */
    @ApiModelProperty("试题图片")
    private String questionImg;

    /**
     * 选项类型
     */
    @ApiModelProperty("选项类型")
    private Integer optionType;

    /**
     * 分值
     */
    @ApiModelProperty("分值")
    private double score;

    /**
     * 是否删除
     */
    @ApiModelProperty("是否删除")
    private Integer isDelete;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @ApiModelProperty("修改时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 选项列表
     */
    @ApiModelProperty("选项列表")
    private List<PracticeUserQuestionOption> optList;
    /**
     * 选中绑定
     */
    @ApiModelProperty("单选选中绑定")
    private String checked;
    /**
     * 是否正确
     */
    @ApiModelProperty("是否正确")
    private Integer isRight;

    /**
     * 收藏
     */
    @ApiModelProperty("收藏?")
    private Boolean collect;
    /**
     * 选中绑定
     */
    @ApiModelProperty("选中绑定集合")
    private List<String> checkedList;

    /**
     * 试题描述
     */
    @ApiModelProperty("试题解析")
    private String answerKey;


    public QueAndOptDto(PracticeUserQuestion examQuestion) {
        this.id = examQuestion.getId();
        this.userId = examQuestion.getUserId();
        this.bankQuestionId=examQuestion.getBankQuestionId();
        this.practiceId = examQuestion.getPracticeId();
        this.questionNum = Math.toIntExact(examQuestion.getQuestionNum());
        this.questionDesc = examQuestion.getQuestionDesc();
        this.questionImg = examQuestion.getQuestionImg();
        this.optionType = examQuestion.getOptionType();
        this.score = examQuestion.getScore();
        this.isDelete = examQuestion.getIsDelete();
        this.createTime = examQuestion.getCreateTime();
        this.updateTime = examQuestion.getUpdateTime();
        this.answerKey=examQuestion.getAnswerKey();
        this.checkedList = new ArrayList<>();
    }

}
